package cn.edu.neusoft.amicooldemo.model;

import java.util.List;

import cn.edu.neusoft.amicooldemo.adapter.UserAdapter;
import cn.edu.neusoft.amicooldemo.bean.FocusResult;

import cn.edu.neusoft.amicooldemo.bean.UserBean;

import cn.edu.neusoft.amicooldemo.iface.FocusListIface;
import cn.edu.neusoft.amicooldemo.iface.FocusListListener;

import cn.edu.neusoft.amicooldemo.service.FocusUserService;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by Neusoft on 2016/12/21.
 */

public class MyFocusModel extends BaseModel implements FocusListIface<UserBean> {
    private FocusUserService service;
    private static MyFocusModel model;
    private List<FocusResult<UserBean>> list;
    private UserAdapter adapter;

    public MyFocusModel(){
        super();
    }
    public static MyFocusModel getInstance(){
        if(model==null){
            model = new MyFocusModel();

        }
        return model;
    }


    @Override
    public void getResultList(String mod, int page, String sessionID, final FocusListListener<UserBean> listener) {
        service = createService(FocusUserService.class);
        Call<List<FocusResult<UserBean>>> call = service.getFocusUserList(mod,page,sessionID);
        call.enqueue(new Callback<List<FocusResult<UserBean>>>() {
            @Override
            public void onResponse(Call<List<FocusResult<UserBean>>> call, Response<List<FocusResult<UserBean>>> response) {
                list = response.body();
                listener.onResponse(list);
            }

            @Override
            public void onFailure(Call<List<FocusResult<UserBean>>> call, Throwable t) {
                listener.onFail(t.toString());
            }

        });
    }

    @Override
    public void getResultBean(String mod, int id, String sessionID, FocusListListener<UserBean> listener) {

    }
}
